/*
 * Copyright (c) 2005, 2020, Jin Lin All rights reserved.
 * Jin Lin PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 */
package aco.entity.dobject;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述 效率.
 *
 * @author Jin Lin
 * @created 2019 -06-30 13:16:17
 */
public class Efficiency {

    /**
     * 节点列表.
     */
    private List<Node> nodes;

    /**
     * 描述 节点数量.
     *
     * @return the long
     * @author Jin Lin
     * @created 2019 -06-30 13:20:50 Length of nodes long.
     */
    public Long lengthOfNodes() {
        return Long.parseLong(getNodes().size() + "");
    }

    /**
     * 描述 创建随机节点.
     *
     * @param length the length
     * @param min    the min
     * @param max    the max
     * @author Jin Lin
     * @created 2019 -06-30 15:17:52 Init random nodes.
     */
    public void initRandomNodes(Long length, Long min, Long max) {
        List<Node> nodes = new ArrayList<>();
        for (Long i = 0L; i < length; i++) {
            Node node = new Node();
            node.setUnitRate(new Double(Math.random() * (max - min) + min).longValue());
            nodes.add(node);
        }
        setNodes(nodes);
    }

    //=======================================================================

    /**
     * Instantiates a new Efficiency.
     */
    public Efficiency() {
    }

    /**
     * Instantiates a new Efficiency.
     *
     * @param nodes the nodes
     */
    public Efficiency(List<Node> nodes) {
        this.nodes = nodes;
    }

    /**
     * 描述 Gets nodes.
     *
     * @return the nodes
     * @author Jin Lin
     * @created 2019 -06-30 13:16:17
     */
    public List<Node> getNodes() {
        return nodes;
    }

    /**
     * 描述 Sets nodes.
     *
     * @param nodes the nodes
     * @author Jin Lin
     * @created 2019 -06-30 13:16:17
     */
    public void setNodes(List<Node> nodes) {
        this.nodes = nodes;
    }
}
